project(
    'walcs-utils',
    'fortran',
    version: '0.1.0',
    license: 'MIT',
    meson_version: '>= 1.0.0',
    default_options: ['buildtype=release', 'fortran_std=f2008'],
)

f_compiler = meson.get_compiler('fortran')
fargs = ['-ffree-line-length-none', '-fimplicit-none', '-cpp']

if host_machine.system() == 'windows'
    fargs += ['-D_WIN32']
endif

# GCC Fortran 15.0 BUG
if (f_compiler.version().version_compare('>= 15.0') and
f_compiler.version().version_compare('< 16.0'))
    fargs += '-Wno-external-argument-mismatch'
    message('Applying GCC Fortran 15.0 bug workaround')
endif

utils_src = files()
subdir('src')

utils_lib = library(
    meson.project_name(),
    utils_src,
    version: meson.project_version(),
    dependencies: [
        dependency('fortran_stdlib', version: '0.7.0', method: 'pkg-config'),
        dependency('openblas', version: '>= 0.3.17'),
        dependency('openmp', version: '>= 4.5'),
    ],
    fortran_args: fargs,
    install: true,
)
utils_dep = declare_dependency(
    link_with: utils_lib,
    include_directories: utils_lib.private_dir_include(),
)

